import { defineStore } from "pinia";
import { reactive, ref } from "vue";
import type { courseForm } from "@/api/type";
// export const useCourseStore = defineStore(
//   "course",
//   () => {
//     var courseInfo = reactive<courseForm[]>([

//     ]);
//     const setCourseInfo = (course: courseForm[]) => {
//       courseInfo = course;
//     };
//     const removeCourseInfo = () => {
//       courseInfo = [];
//     };
//     return { courseInfo, setCourseInfo, removeCourseInfo };
//   },
//   { persist: true }
// );

export const useCourseStore = defineStore("course", {
  state: () => {
    return {
      activeName: ref("first"),
      courseInfo: reactive<courseForm[]>([]),
    };
  },
  actions: {
    setActiveName(name: string) {
      this.activeName = name;
    },
    setCourseInfo(course: courseForm[]) {
      this.courseInfo = course;
    },
    removeCourseInfo() {
      this.courseInfo = [];
      this.activeName = "first";
    },
  },
  persist: true,
});
export default useCourseStore;
